package com.kaifamiao.www.demo.Do28;

public class Sup {
    int a = 1;
    static int b = 2;
    {
        System.out.println("Sup:{}");
    }
    static {
        System.out.println("sup:static{}");
    }
    public Sup(){
        System.out.println("Sup()");
    }
    public Sup (int a){
        System.out.println("Sup(int a)");
    }
    public void instanceMethod(){
        System.out.println("Sup::instanceMethod");
    }
    public static void staticMethod(){
        System.out.println("Sup:staticMethod");
    }
}
class Sub extends Sup{
    static int a = 3;
    int b = 4;
    {
        System.out.println("Sub:{}");
    }
    static {
        System.out.println("Sub:static");
    }
    // super 关键字在子类中使用, 表示 父类对象。 super 调用父类的成员  super([参数列表]) 调用父类构造
    public Sub(){
           // super(2);
        // super(); // 先调用父类，进行父类实例化. 必须在构造的第一行
        System.out.println("Sub()");
    }
   public void show(){
       System.out.println("a="+a);//3 this.a
       System.out.println("this.a="+this.a);//3  this.a
       System.out.println("super.a="+super.a);//1
       System.out.println("b="+b);//4  this.b
       System.out.println("this.b="+this.b);//4 this.b
       System.out.println("super.b="+super.b);//2
   }
   @Override
   public void instanceMethod(){
       System.out.println("sub::instanceMethod");
   }
   public static void staticMethod(){
       System.out.println("sub:staticMethod");
   }
}
